home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / ForCLI / infolist.lha / Infolist / developer / xfd / autodoc / xfdmaster.doc
Encoding:
Text File  |  1995-01-05  |  21.8 KB  |  677 lines

  1. TABLE OF CONTENTS
  2.  
  3. xfdmaster.library/--Overview--
  4. xfdmaster.library/xfdAllocBufferInfo
  5. xfdmaster.library/xfdAllocSegmentInfo
  6. xfdmaster.library/xfdDecrunchBuffer
  7. xfdmaster.library/xfdDecrunchSegment
  8. xfdmaster.library/xfdFreeBufferInfo
  9. xfdmaster.library/xfdFreeSegmentInfo
  10. xfdmaster.library/xfdGetErrorText
  11. xfdmaster.library/xfdRecogBuffer
  12. xfdmaster.library/xfdRecogSegment
  13. xfdmaster.library/xfdRelocate
  14. xfdmaster.library/xfdTestHunkStructure
  15. xfdmaster.library/xfdTestHunkStructureNew
  16. xfdForeman/--Overview--
  17. xfdSlave/--Overview--
  18. xfdSlave/RecogBufferXYZ
  19. xfdSlave/DecrunchBufferXYZ
  20. xfdSlave/RecogSegmentXYZ
  21. xfdSlave/DecrunchSegmentXYZ
  22.  
  23. xfdmaster.library/--Overview--                 xfdmaster.library/--Overview--
  24.  
  25. This section describes the usual way how to use xfdmaster.library from your
  26. own applications.
  27.  
  28. If you want to decrunch files from a buffer, do it like this:
  29.  
  30. 1.  Call xfdAllocBufferInfo(). If not successful, go on with 12.
  31. 2.  Get file size, allocate buffer with that size and load file to buffer.
  32.     If not successful, go on with 10.
  33. 3.  Call xfdRecogBuffer() with xfdbi_SourceBuffer and xfdbi_SourceBufLen
  34.     initialized. If not successful, file is not crunched and you may work
  35.     with that file as it is, release the used memory and go on with 10.
  36. 4.  Check xfdbi_PackerFlags for XFDPFB_PASSWORD, go on with 6. if not set.
  37. 5.  Get password (maximum length is stored in xfdbi_MaxSpecialLen) and
  38.     store a pointer to it in xfdbi_Special.
  39. 6.  Initialize xfdbi_TargetBufMemType and call xfdDecrunchBuffer(). If not
  40.     successful, work with crunched file, release memory afterwards and
  41.     go on with 10.
  42. 7.  Release memory of xfdbi_SourceBuffer.
  43. 8.  Work with decrunched file.
  44. 9.  Release memory of xfdbi_TargetBuffer.
  45. 10. If you have another file to decrunch, step back to 2.
  46. 11. Call xfdFreeBufferInfo().
  47. 12. Exit!
  48.  
  49. If you want to decrunch a segment list, do it like this:
  50.  
  51. 1.  Call xfdAllocSegmentInfo(). If not successful, go on with 11.
  52. 2.  dos.library/LoadSeg() file. If not successful, go on with 9.
  53. 3.  Call xfdRecogSegment() with xfdsi_SegList initialized. If not
  54.     successful, seglist isn't crunched and you may go on with 7.
  55. 4.  Check xfdsi_PackerFlags for XFDPFB_PASSWORD. If set, get password
  56.     (maximum length is stored in xfdsi_MaxSpecialLen) and store a pointer
  57.     to it in xfdsi_Special.
  58. 5.  (V34) Check xfdsi_PackerFlags for XFDPFB_RELMODE. If set, init
  59.     xfdsi_RelMode with the desired value.
  60. 6.  Call xfdDecrunchSegment(). If not successful, test xfdsi_SegList.
  61.     If this field contains NULL, no seglist is available anymore. You
  62.     have to dos.library/LoadSeg() the file again then.
  63. 7.  Work with segment list.
  64. 8.  dos.library/UnloadSeg() segment list.
  65. 9.  If you have another segment list to decrunch, step back to 2.
  66. 10. Call xfdFreeSegmentInfo().
  67. 11. Exit!
  68.  
  69. Whenever you intend to use a feature of the xfdmaster.library that is
  70. marked (V34) or higher, make sure that you use this version number
  71. during the exec.library/OpenLibrary() call. Otherwise, if you try to
  72. use new features with an old library version, the system might crash.
  73.  
  74. xfdmaster.library/xfdAllocBufferInfo     xfdmaster.library/xfdAllocBufferInfo
  75.  
  76.    NAME
  77.     xfdAllocBufferInfo -- Allocate memory for BufferInfo structure.
  78.  
  79.    SYNOPSIS
  80.     bufferinfo = xfdAllocBufferInfo()
  81.         D0              -30
  82.  
  83.     struct xfdBufferInfo *xfdAllocBufferInfo(void);
  84.  
  85.    FUNCTION
  86.     Allocates a memory block large enough to hold all information of
  87.     the xfdBufferInfo structure. Never do this in any other way for
  88.     compatibility with library updates.
  89.  
  90.    INPUTS
  91.     None.
  92.  
  93.    RESULT
  94.     bufferinfo - Pointer to the xfdBufferInfo structure or NULL if
  95.                  there occured an error.
  96.  
  97.    SEE ALSO
  98.     xfdFreeBufferInfo()
  99.  
  100. xfdmaster.library/xfdAllocSegmentInfo   xfdmaster.library/xfdAllocSegmentInfo
  101.  
  102.    NAME
  103.     xfdAllocSegmentInfo -- Allocate memory for SegmentInfo structure.
  104.  
  105.    SYNOPSIS
  106.     segmentinfo = xfdAllocSegmentInfo()
  107.         D0                -42
  108.  
  109.     struct xfdSegmentInfo *xfdAllocSegmentInfo(void);
  110.  
  111.    FUNCTION
  112.     Allocates a memory block large enough to hold all information of
  113.     the xfdSegmentInfo structure. Never do this in any other way for
  114.     compatibility with library updates.
  115.  
  116.    INPUTS
  117.     None.
  118.  
  119.    RESULT
  120.     segmentinfo - Pointer to the xfdSegmentInfo structure or NULL if
  121.                   there occured an error.
  122.  
  123.    SEE ALSO
  124.     xfdFreeSegmentInfo()
  125.  
  126. xfdmaster.library/xfdDecrunchBuffer       xfdmaster.library/xfdDecrunchBuffer
  127.  
  128.    NAME
  129.     xfdDecrunchBuffer -- Decrunch a file from buffer.
  130.  
  131.    SYNOPSIS
  132.     success = xfdDecrunchBuffer(bufferinfo)
  133.       D0             -60            A0
  134.  
  135.     BOOL xfdDecrunchBuffer(struct xfdBufferInfo *);
  136.  
  137.    FUNCTION
  138.     Decrunches a file to a separate buffer. You have to call
  139.     xfdRecogBuffer() first, only if this call was successful,
  140.     you may call xfdDecrunchBuffer().
  141.  
  142.     You have to pass the type of memory that should be used for
  143.     the target buffer in xfdbi_TargetBufMemType.
  144.     Additionally you have to init the xfdbi_Special field with
  145.     a pointer to a special info buffer if any special flags are
  146.     set in the xfdbi_PackerFlags field. The contents of this
  147.     buffer depend on the type of special info (eg. password).
  148.  
  149.     If the decrunching was successful, the following fields in
  150.     the xfdBufferInfo structure will be initialized:
  151.  
  152.     xfdbi_TargetBuffer     - Pointer to decrunched file buffer.
  153.     xfdbi_TargetBufSaveLen - Length of decrunched file (for saving etc.).
  154.     xfdbi_TargetBufLen     - Total length of allocated buffer.
  155.     xfdbi_DecrAddress      - If XFDPFB_ADDR is set in xfdbi_PackerFlags,
  156.                              this contains the address where the crunched
  157.                              file has been relocated to.
  158.     xfdbi_JmpAddress       - If XFDPFB_ADDR is set in xfdbi_PackerFlags,
  159.                              this contains the address where to jump at
  160.                              in order to run the file.
  161.  
  162.    INPUTS
  163.     bufferinfo - Pointer to an initialized xfdBufferInfo structure:
  164.        xfdbi_TargetBufMemType - Type of memory for target buffer.
  165.        xfdbi_Special          - Pointer to special info if required.
  166.  
  167.    RESULT
  168.     success - TRUE if decrunching was successful, FALSE if
  169.               anything went wrong.
  170.  
  171.    NOTE
  172.     xfdDecrunchBuffer() allocates a buffer for the decrunched file,
  173.     but it doesn't release this memory afterwards. That is because
  174.     you first have to work with the decrunched file (what else?).
  175.     Therefore you have to do a call to exec.library/FreeMem() after
  176.     you finished work. Use the following parameters:
  177.     xfdbi_TargetBufLen - Lenght of buffer.
  178.     xfdbi_TargetBuffer - Pointer to buffer.
  179.  
  180.     Don't forget:
  181.     xfdbi_TargetBufLen contains the length of the allocated memory
  182.     area, xfdbi_TargetBufSaveLen the length of the decrunched file
  183.     in that buffer.
  184.  
  185.     xfdDecrunchBuffer() never touches the buffer that contains the
  186.     crunched file. It's again your task to release this after
  187.     decrunching.
  188.  
  189.    SEE ALSO
  190.     xfdRecogBuffer(), exec.library/FreeMem()
  191.  
  192. xfdmaster.library/xfdDecrunchSegment     xfdmaster.library/xfdDecrunchSegment
  193.  
  194.    NAME
  195.     xfdDecrunchSegment -- Decrunch a file from its segment list.
  196.  
  197.    SYNOPSIS
  198.     success = xfdDecrunchSegment(segmentinfo)
  199.       D0             -72             A0
  200.  
  201.     BOOL xfdDecrunchSegment(struct xfdSegmentInfo *);
  202.  
  203.    FUNCTION
  204.     Decrunches a segment list. You have to call xfdRecogSegment()
  205.     first, only if this call was successful, you may call
  206.     xfdDecrunchSegment().
  207.  
  208.     You have to init the xfdsi_Special field with a pointer to a
  209.     special info buffer if any special flags are set in the
  210.     xfdsi_PackerFlags field. The contents of this buffer depend on
  211.     the type of special info (eg. password).
  212.  
  213.     (V34) Check xfdsi_Packerflags for XFDPFB_RELMODE. If set,
  214.     initialize xfdsi_RelMode with the desired XFDREL_#? value.
  215.  
  216.     If decrunching was successful, xfdsi_SegList holds a BPTR to
  217.     the decrunched segment list. The old segment list has been
  218.     released and/or replaced by the new one (depends on cruncher).
  219.  
  220.     If decrunching failed, xfdsi_SegList may be NULL. This happens
  221.     if an error occured after the seglist has already been changed
  222.     in any way. It then will be released.
  223.     Otherwise, if xfdsi_SegList is not NULL, it still contains a
  224.     valid BPTR to the crunched segment list.
  225.  
  226.    INPUTS
  227.     segmentinfo - Pointer to an initialized xfdSegmentInfo structure:
  228.        xfdsi_Special - Pointer to special info if required.
  229.        xfdsi_RelMode - (V34) XFDREL_#? value if required.
  230.  
  231.    RESULT
  232.     success - TRUE if decrunching was successful, FALSE if
  233.               anything went wrong.
  234.  
  235.    NOTE
  236.     If you no longer need the decrunched segment list, you may
  237.     release it by simply calling dos.library/UnloadSeg().
  238.  
  239.    SEE ALSO
  240.     xfdRecogSegment(), dos.library/UnloadSeg()
  241.  
  242. xfdmaster.library/xfdFreeBufferInfo       xfdmaster.library/xfdFreeBufferInfo
  243.  
  244.    NAME
  245.     xfdFreeBufferInfo -- Free memory of xfdBufferInfo structure.
  246.  
  247.    SYNOPSIS
  248.     xfdFreeBufferInfo(bufferinfo)
  249.            -36            A1
  250.  
  251.     void xfdFreeBufferInfo(struct xfdBufferInfo *);
  252.  
  253.    FUNCTION
  254.     Deallocates the memory reserved via xfdAllocBufferInfo().
  255.  
  256.    INPUTS
  257.     bufferinfo - Pointer to xfdBufferInfo structure.
  258.  
  259.    RESULT
  260.     None.
  261.  
  262.    SEE ALSO
  263.     xfdAllocBufferInfo()
  264.  
  265. xfdmaster.library/xfdFreeSegmentInfo     xfdmaster.library/xfdFreeSegmentInfo
  266.  
  267.    NAME
  268.     xfdFreeSegmentInfo -- Free memory of xfdSegmentInfo structure.
  269.  
  270.    SYNOPSIS
  271.     xfdFreeSegmentInfo(segmentinfo)
  272.            -48             A1
  273.  
  274.     void xfdFreeSegmentInfo(struct xfdSegmentInfo *);
  275.  
  276.    FUNCTION
  277.     Deallocates the memory reserved via xfdAllocSegmentInfo().
  278.  
  279.    INPUTS
  280.     segmentinfo - Pointer to xfdSegmentInfo structure.
  281.  
  282.    RESULT
  283.     None.
  284.  
  285.    SEE ALSO
  286.     xfdAllocSegmentInfo()
  287.  
  288. xfdmaster.library/xfdGetErrorText           xfdmaster.library/xfdGetErrorText
  289.  
  290.    NAME
  291.     xfdGetErrorText -- Get an ascii string from an error number.
  292.  
  293.    SYNOPSIS
  294.     string = xfdGetErrorText(error)
  295.       D0           -78        D0.w
  296.  
  297.     STRPTR xfdGetErrorText(UWORD);
  298.  
  299.    FUNCTION
  300.     Whenever a library call fails, you receive an error number either
  301.     in the xfd#?_Error field or directly as a returncode. This function
  302.     gets the corresponding ascii string to the occured error.
  303.  
  304.    INPUTS
  305.     error - Error number from xfd#?_Error or returncode.
  306.  
  307.    RESULT
  308.     string - Pointer to an ascii string that describes the error.
  309.  
  310.    SEE ALSO
  311.     xfdDecrunchBuffer(), xfdDecrunchSegment(), xfdRelocate(),
  312.     xfdTestHunkStructureNew()
  313.  
  314. xfdmaster.library/xfdRecogBuffer             xfdmaster.library/xfdRecogBuffer
  315.  
  316.    NAME
  317.     xfdRecogBuffer -- Examine buffer for crunched file.
  318.  
  319.    SYNOPSIS
  320.     success = xfdRecogBuffer(bufferinfo)
  321.       D0             -54         A0
  322.  
  323.     BOOL xfdRecogBuffer(struct xfdBufferInfo *);
  324.  
  325.    FUNCTION
  326.     Examines a file for known crunchers. You pass a pointer to
  327.     the file buffer in xfdbi_SourceBuffer and the length of the
  328.     buffer in xfdbi_SourceBufLen.
  329.  
  330.     If a crunched file has been recognized, the following fields
  331.     in the xfdBufferInfo structure will be initialized:
  332.  
  333.     xfdbi_PackerName    - Pointer to the name of the cruncher.
  334.     xfdbi_PackerFlags   - Contains the packer type and additional
  335.                           information (eg. password).
  336.     xfdbi_MaxSpecialLen - Only used if any special flags are set.
  337.  
  338.    INPUTS
  339.     bufferinfo - Pointer to an initialized xfdBufferInfo structure:
  340.        xfdbi_SourceBuffer - Pointer to file buffer.
  341.        xfdbi_SourceBufLen - Length of file buffer.
  342.  
  343.    RESULT
  344.     success - TRUE if a cruncher has been recognized, FALSE if
  345.               file is unknown.
  346.  
  347.    SEE ALSO
  348.     xfdDecrunchBuffer()
  349.  
  350. xfdmaster.library/xfdRecogSegment           xfdmaster.library/xfdRecogSegment
  351.  
  352.    NAME
  353.     xfdRecogSegment -- Examine segment list for crunched file.
  354.  
  355.    SYNOPSIS
  356.     success = xfdRecogSegment(segmentinfo)
  357.       D0             -66          A0
  358.  
  359.     BOOL xfdRecogSegment(struct xfdSegmentInfo *);
  360.  
  361.    FUNCTION
  362.     Examines a segment list for known crunchers. You pass a BPTR
  363.     to the segment list in xfdsi_SegList.
  364.  
  365.     If a crunched segment list has been recognized, the following
  366.     fields in the xfdSegmentInfo structure will be initialized:
  367.  
  368.     xfdsi_PackerName    - Pointer to the name of the cruncher.
  369.     xfdsi_PackerFlags   - Contains the packer type and additional
  370.                           information (eg. password).
  371.     xfdsi_MaxSpecialLen - Only used if any special flags are set.
  372.  
  373.    INPUTS
  374.     segmentinfo - Pointer to an initialized xfdSegmentInfo structure:
  375.        xfdsi_SegList - BPTR to segment list.
  376.  
  377.    RESULT
  378.     success - TRUE if a cruncher has been recognized, FALSE if
  379.               segment list is unknown.
  380.  
  381.    SEE ALSO
  382.     xfdDecrunchSegment()
  383.  
  384. xfdmaster.library/xfdRelocate                   xfdmaster.library/xfdRelocate
  385.  
  386.    NAME
  387.     xfdRelocate -- Create segment list from file buffer. (V34)
  388.  
  389.    SYNOPSIS
  390.     error = xfdRelocate(buffer, length, result, mode)
  391.      D0.w       -96       A0      D0      A1    D1.w
  392.  
  393.     UWORD xfdRelocate(APTR, ULONG, ULONG *, UWORD);
  394.  
  395.    FUNCTION
  396.     Creates a relocated and fully executable segment list from
  397.     a file buffer. The result is a BPTR to the first segment,
  398.     similar to the result of a call to dos.library/LoadSeg().
  399.  
  400.    INPUTS
  401.     buffer - Pointer to the file buffer that should be relocated.
  402.     length - Length of the file buffer.
  403.     result - Pointer to the longword that should hold the result.
  404.     mode   - Any XFDREL_#? relocation mode.
  405.  
  406.    RESULT
  407.     error  - XFDERR_OK if no error occured, else XFDERR_#?.
  408.     result - Holds a BPTR to the first segment if error = XFDERR_OK.
  409.  
  410.    NOTE
  411.     There is no need to call xfdTestHunkStructure[New]() before
  412.     relocation because xfdRelocate() does this already.
  413.  
  414.     This routine supports the following hunk types:
  415.     - hunk_unit    ($3e7) -> Skipped.
  416.     - hunk_name    ($3e8) -> Skipped.
  417.     - hunk_code    ($3e9) -> Creates new code segment.
  418.     - hunk_data    ($3ea) -> Creates new data segment.
  419.     - hunk_bss     ($3eb) -> Creates new bss segment.
  420.     - hunk_reloc32 ($3ec) -> Used for relocation.
  421.     - hunk_ext     ($3ef) -> Skipped.
  422.     - hunk_symbol  ($3f0) -> Skipped.
  423.     - hunk_debug   ($3f1) -> Skipped.
  424.     - hunk_end     ($3f2) -> May be left out.
  425.     Any other hunk types create an error. There is no support for
  426.     hunk_overlay, because the main purpose of this routine is to
  427.     be called from xfds_DecrunchSegment. And in that case, the real
  428.     dos.library/LoadSeg() has already initialized the overlay header.
  429.  
  430. xfdmaster.library/xfdTestHunkStructure xfdmaster.library/xfdTestHunkStructure
  431.  
  432.    NAME
  433.     xfdTestHunkStructure -- Test hunks of executable file.
  434.  
  435.    SYNOPSIS
  436.     success = xfdTestHunkStructure(buffer, length)
  437.       D0              -84            A0      D0
  438.  
  439.     BOOL xfdTestHunkStructure(APTR, ULONG);
  440.  
  441.    FUNCTION
  442.     Checks an executable file for a valid hunk structure.
  443.     This is important for decrunching files, because an incomplete
  444.     or damaged file may cause a system crash.
  445.  
  446.    INPUTS
  447.     buffer - Pointer to the file buffer that should be checked.
  448.     length - Length of the file buffer.
  449.  
  450.    RESULT
  451.     success - TRUE if file is ok, FALSE if file is damaged.
  452.  
  453.    SEE ALSO
  454.     xfdTestHunkStructureNew()
  455.  
  456. xfdmaster.lib/xfdTestHunkStructureNew   xfdmaster.lib/xfdTestHunkStructureNew
  457.  
  458.    NAME
  459.     xfdTestHunkStructureNew -- Test hunks of executable file. (V34)
  460.  
  461.    SYNOPSIS
  462.     error = xfdTestHunkStructureNew(buffer, length)
  463.      D0.w           -90               A0      D0
  464.  
  465.     UWORD xfdTestHunkStructureNew(APTR, ULONG);
  466.  
  467.    FUNCTION
  468.     Checks an executable file for a valid hunk structure.
  469.     This is important for decrunching files, because an incomplete
  470.     or damaged file may cause a system crash.
  471.  
  472.    INPUTS
  473.     buffer - Pointer to the file buffer that should be checked.
  474.     length - Length of the file buffer.
  475.  
  476.    RESULT
  477.     error - XFDERR_OK if file is ok, XFDERR_#? if file is damaged.
  478.  
  479.    NOTE
  480.     You don't have to call this function before trying to decrunch
  481.     a file, because xfdDecrunchBuffer() does this already.
  482.  
  483.     This hunk checker supports all standard hunk types from
  484.     hunk_unit ($3e7) to hunk_index ($3fb).
  485.     It recognizes the standard hunk_overlay ($3f5) format and some
  486.     user-defined overlay types too. Anyway, it may happen that some
  487.     weird overlay hunk causes problems because there isn't any real
  488.     definition for overlays.
  489.     The hunk structure of a non-overlayed file will nevertheless
  490.     be checked 100% correctly.
  491.  
  492.    SEE ALSO
  493.     xfdTestHunkStructure()
  494.  
  495. xfdForeman/--Overview--                               xfdForeman/--Overview--
  496.  
  497. The xfdForeman structure is just some kind of header for external slaves.
  498. It protects the slaves from being executed accidentally by having a small
  499. piece of code (moveq #-1,d0 : rts) in the first 4 bytes.
  500. The master can identify a valid bunch of external slaves by checking the
  501. first few bytes of the file for the foreman identification.
  502. Finally, a foreman holds the pointer to a linked list of slaves and thus
  503. enables the master to work with these slaves.
  504.  
  505. xfdSlave/--Overview--                                   xfdSlave/--Overview--
  506.  
  507. The xfdSlave structure is the heart of the whole library system. Each slave
  508. enables the master to recognize and decrunch packed files and/or segments.
  509.  
  510. Therefore each slave contains 4 routines that are called from the master.
  511. Pointers to these routines are stored in xfds_Recog#? and xfds_Decrunch#?.
  512. All have one thing in common: the CPU registers D0/D1/A0/A1 are so called
  513. scratch registers, they may change during execution, all other registers
  514. must remain unchanged. CPU register A6 holds a pointer to the xfdMasterBase
  515. structure. See chapters below for a description of the slave routines.
  516.  
  517. ALL SLAVE ROUTINES MUST BE REENTRANT! NEVER STORE ANY DATA IN STATIC MEMORY
  518. AREAS, USE THE STACK OR SOME ALLOCATED MEMORY INSTEAD! REMEMBER THAT THE
  519. ROUTINES MIGHT BE CALLED BY SEVERAL PROGRAMS AT THE SAME TIME!
  520.  
  521. The name of the packer that is supported by the slave and the flags that
  522. describe the packer are stored in xfds_PackerName and xfds_PackerFlags.
  523.  
  524. Whenever you intend to use features of the xfdmaster.library in your slaves
  525. that are marked (V34) or higher, make sure to set xfds_MasterVersion to
  526. the desired version number, otherwise an old library version might crash
  527. while using the new slave.
  528.  
  529. xfdSlave/RecogBufferXYZ                               xfdSlave/RecogBufferXYZ
  530.  
  531.    NAME
  532.     RecogBufferXYZ -- Recognize crunched file in buffer.
  533.  
  534.    SYNOPSIS
  535.     result = RecogBufferXYZ(buffer, length)
  536.       D0                      A0      D0
  537.  
  538.     BOOL RecogBufferXYZ(APTR, ULONG);
  539.  
  540.    FUNCTION
  541.     This routine should examine the buffer for a crunched file.
  542.     First thing is to check if the size of the file allows it to
  543.     be crunched with the packer in question. After that, simply
  544.     do some compares to figure out if the file has been crunched
  545.     or not.
  546.  
  547.    INPUTS
  548.     buffer - Pointer to a buffer that holds the crunched file.
  549.     length - Length of that buffer.
  550.  
  551.    RESULT
  552.     result - TRUE if packer has been recognized, else FALSE.
  553.  
  554.    NOTE
  555.     You have to initialize xfds_RecogBuffer with a pointer to your
  556.     RecogBufferXYZ routine.
  557.  
  558.    SEE ALSO
  559.     Example sourcecodes.
  560.  
  561. xfdSlave/DecrunchBufferXYZ                         xfdSlave/DecrunchBufferXYZ
  562.  
  563.    NAME
  564.     DecrunchBufferXYZ -- Decrunch file from buffer to buffer.
  565.  
  566.    SYNOPSIS
  567.     result = DecrunchBufferXYZ(bufferinfo)
  568.       D0                           A0
  569.  
  570.     BOOL DecrunchBufferXYZ(struct xfdBufferInfo *);
  571.  
  572.    FUNCTION
  573.     The typical steps of such a routine are:
  574.     - Get length of decrunched file (exactly or a bit too much).
  575.     - Allocate memory (with memtype from xfdbi_TargetBufMemType).
  576.     - Decrunch file from xfdbi_SourceBuffer to xfdbi_TargetBuffer.
  577.     - Initialize all necessary parts of the xfdBufferInfo structure.
  578.     - Set xfdbi_Error if an error occurs.
  579.  
  580.    INPUTS
  581.     bufferinfo - A valid xfdBufferInfo structure that successfully went
  582.                  through a call to xfdRecogBuffer().
  583.  
  584.    RESULT
  585.     result - TRUE if decrunching succeeded, FALSE if something went wrong.
  586.  
  587.    NOTE
  588.     You have to initialize xfds_DecrunchBuffer with a pointer to your
  589.     DecrunchBufferXYZ routine.
  590.  
  591.    SEE ALSO
  592.     Example sourcecodes.
  593.  
  594. xfdSlave/RecogSegmentXYZ                             xfdSlave/RecogSegmentXYZ
  595.  
  596.    NAME
  597.     RecogSegmentXYZ -- Recognize crunched segment list.
  598.  
  599.    SYNOPSIS
  600.     result = RecogSegmentXYZ(seglist)
  601.       D0                       A0
  602.  
  603.     BOOL RecogSegmentXYZ(BPTR);
  604.  
  605.    FUNCTION
  606.     This routine should examine if a segment list is crunched.
  607.     You can check the whole segment list for correct lengths of hunks
  608.     and for contents of hunks if you like. There should be at least
  609.     3 comparations to determine the cruncher.
  610.  
  611.    INPUTS
  612.     seglist - BPTR to first segment.
  613.  
  614.    RESULT
  615.     result - TRUE if packer has been recognized, else FALSE.
  616.  
  617.    NOTE
  618.     You have to initialize xfds_RecogSegment with a pointer to your
  619.     RecogSegmentXYZ routine.
  620.  
  621.    SEE ALSO
  622.     Example sourcecodes.
  623.  
  624. xfdSlave/DecrunchSegmentXYZ                       xfdSlave/DecrunchSegmentXYZ
  625.  
  626.    NAME
  627.     DecrunchSegmentXYZ -- Decrunch segment list.
  628.  
  629.    SYNOPSIS
  630.     result = DecrunchSegmentXYZ(segmentinfo)
  631.       D0                             A0
  632.  
  633.     BOOL DecrunchSegmentXYZ(struct xfdSegmentInfo *);
  634.  
  635.    FUNCTION
  636.     There are two possibilities how to decrunch a segment list. The
  637.     first one works like this:
  638.     - Modify decrunch header to make it return to the caller.
  639.     - Call decrunch header.
  640.     - dos.library/UnloadSeg() whole seglist and clear xfdsi_SegList
  641.       if an error occurs and the seglist has already been altered
  642.       in any way.
  643.     - Otherwise only release segments that are no longer necessary.
  644.     - Store BPTR to first hunk of decrunched segment list in
  645.       xfdsi_SegList.
  646.     - Set xfdsi_Error if an error occurs.
  647.  
  648.     The second possibility works the same way as the first with
  649.     the difference that you don't jump to the original code, but you
  650.     include all necessary parts of it (decrunch routine, relocator)
  651.     in your own routine. The big advantage is that you can handle
  652.     error conditions much better because most of the standard decrunch
  653.     headers in executable files have problems with low memory etc.
  654.  
  655.     (V34) If the decruncher allows it, always support XFDPFB_RELMODE.
  656.     That way the caller can determine the type of memory the segments
  657.     should be placed in by initializing xfdsi_RelMode with XFDREL_#?.
  658.  
  659.     Many crunchers don't change the hunk structure of the crunched
  660.     data. If this is the case, you can simply call the decrunch code
  661.     in the segment list and then use xfdRelocate() (V34).
  662.  
  663.    INPUTS
  664.     segmentinfo - A valid xfdSegmentInfo structure that successfully went
  665.                   through a call to xfdRecogSegment().
  666.  
  667.    RESULT
  668.     result - TRUE if decrunching succeeded, FALSE if something went wrong.
  669.  
  670.    NOTE
  671.     You have to initialize xfds_DecrunchSegment with a pointer to your
  672.     DecrunchSegmentXYZ routine.
  673.  
  674.    SEE ALSO
  675.     Example sourcecodes.
  676.  
  677.